package com.xiu.travel.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;

/**
 * @author 2023
 */

@AllArgsConstructor
public enum RoleEnum
{
    /**
     * 系统管理员
     */
    ADMIN("admin","系统管理员",1),
    /**
     * 店长
     */
    STORE_MANAGER("shop_admin","店长",2),
    /**
     * 普通用户
     */
    USER("user","普通用户",3),
    /**
     * 店员
     */
    SHOP_ASSISTANT("shop_user","店员",4),
    /**
     * 仓库管理员
     */
    WAREHOUSE_KEEPER("warehouse_admin","仓库管理员",5),
    /**
     * 门店仓库管理员
     */
    SHOP_WAREHOUSE_ADMIN("shop_warehouse_admin","门店仓库管理员",6),
    /**
     * 门店报损盘库员
     */
    INVENTORY_USER("inventory_user","门店报损盘库员",7),
    /**
     * 门店仓库采购员
     */
    SHOP_WAREHOUSE_PURCHASE("shop_warehouse_purchase","门店仓库采购员",8);
    @EnumValue
    private final String code;
    @JsonValue
    private final String status;
    private final Integer index;

    public String getStatus() {
        return status;
    }
    public String getValue() {
        return code;
    }

    public Integer getIndex()
    {
        return index;
    }

    public static RoleEnum getEnumByCode(String value) {
        for (RoleEnum v : values())
        {
            if (v.getValue().equals(value))
            {
                return v;
            }
        }
        throw new IllegalArgumentException();
    }
    public static RoleEnum getEnumByStatus(String value) {
        for (RoleEnum v : values())
        {
            if (v.getStatus().equals(value))
            {
                return v;
            }
        }
        throw new IllegalArgumentException();
    }
}
